<template>
  <div class="uploadList">
    <el-table :data="tableList" stripe border class="user-table"  style="width: 100%;" v-loading="loading">
      <el-table-column fixed type="index" label="序号" sortable min-width="30"></el-table-column>
      <el-table-column prop="nameName.nameName" label="工序名称" sortable min-width="100"></el-table-column>
      <el-table-column prop="macName" label="设备" sortable min-width="100"></el-table-column>
      <el-table-column prop="resultNums" label="合格数量" sortable min-width="100"></el-table-column>
      <el-table-column prop="content" label=" 检验内容" sortable min-width="100" > </el-table-column>
      <el-table-column prop="planEndTime" label="计划完成时间" sortable min-width="100"></el-table-column>
      <el-table-column prop="startTime" label=" 实际开始时间" sortable min-width="100" > </el-table-column>
      <el-table-column prop="endTime" label=" 实际结束时间" sortable min-width="100" > </el-table-column>
      <el-table-column prop="state" label="是否完成" width="40"  align="center">
        <template slot-scope="scope">
          <span v-if="scope.row.state ===1" class='el-icon-circle-check  cl-success fn-size18 '></span>
        </template>
      </el-table-column>
      <el-table-column prop="creatorName" label=" 检验人" sortable min-width="100" > </el-table-column>
      <el-table-column prop="createTime" label=" 检验时间" sortable min-width="100" > </el-table-column>
      <el-table-column fixed="right" label="操作" align="right" width="80">
        <template slot-scope="scope">
           <el-button @click="showDailog2(scope.row)" type="text" size="small">记录</el-button>
        </template>
      </el-table-column>
    </el-table>

     <!--生产工序 记录列表 -->
    <el-dialog class="bodyNopaddingTop" :title="dialog2.title" :visible.sync="dialog2.isShow" v-dialogDrag :append-to-body="true" >
       <el-form :model="dialog2.formData" ref="ruleForm1" label-width="120px" class="demo-ruleForm" :inline="true">
          <el-form-item label="工序名称111" prop="nameName">
            <el-input v-model="dialog2.formData.nameName.nameName" class="width220" disabled>
            </el-input>
          </el-form-item>
          <el-form-item label="设备" prop="macName">
            <el-input v-model="dialog2.formData.macName" class="width220" disabled></el-input>
          </el-form-item>
          <el-form-item label="合格数量" prop="resultNums" class="form-item-block">
            <el-input v-model="dialog2.formData.resultNums" class="width220"></el-input>
          </el-form-item>
          <el-form-item label="检验内容" prop="content" class="form-item-block">
            <el-input type="textarea" :rows="2" placeholder="请输入检验内容" v-model="dialog2.formData.content" class="width520"></el-input>
          </el-form-item>
          <el-form-item label="计划开始时间" prop="planStartTime">
             <el-date-picker v-model="dialog2.formData.planStartTime" type="datetime" placeholder="选择计划开始时间" class="width220 noMargin"></el-date-picker>
          </el-form-item>
          <el-form-item label="计划结束时间" prop="planEndTime">
             <el-date-picker v-model="dialog2.formData.planEndTime" type="datetime" placeholder="选择计划结束时间" class="width220 noMargin"></el-date-picker>
          </el-form-item>
          <el-form-item label="实际开始时间" prop="startTime">
             <el-date-picker v-model="dialog2.formData.startTime" type="datetime" placeholder="实际计划开始时间" class="width220 noMargin"></el-date-picker>
          </el-form-item>
          <el-form-item label="实际结束时间" prop="endTime">
             <el-date-picker v-model="dialog2.formData.endTime" type="datetime" placeholder="实际计划结束时间" class="width220 noMargin"></el-date-picker>
          </el-form-item>
          <el-form-item label="操作人" prop="creatorName">
            <el-input v-model="dialog2.formData.creatorName" class="width220" disabled>
            </el-input>
          </el-form-item>
          <el-form-item label="操作时间" prop="createTime">
            <el-input v-model="dialog2.formData.createTime" class="width220" disabled></el-input>
          </el-form-item>
          <el-form-item  class="form-item-block text-center" >
            <el-button type="primary" @click="onSubmit()" >确认</el-button>
          </el-form-item>
        </el-form>
    </el-dialog>
 </div>
</template>
<script>
import testApi from 'plugins/axios/testApi.js';
export default {
  name: 'productionRecordList',
  props:{
    tid:{
      type:[String,Number]
    }
  },
  data (){
    return {
      loading:false,
      tableList:[],
      dialog2:{
        title:'',
        isShow:false,
        type:'',
        formData:{
          nameName:''
        }
      }
    }
  },
  watch:{
    
  },
  created(){

  },
  methods:{
   getRecordList(){
     let self = this;
     let postData={
       tid:self.tid
     }
     testApi.testProcessList(postData).then(res=>{
      self.tableList= res.content;
     })
   },
   showDailog2(row){
     let self = this;
     self.dialog2.title = '检验记录';
     self.dialog2.isShow = true;
     self.dialog2.formData = JSON.parse(JSON.stringify(row));
   },
  onSubmit(template){
    let self = this;
    let data ={
        tid: self.dialog2.formData.tid,
        id: self.dialog2.formData.id,
        name:self.dialog2.formData.name,
        resultNums:self.dialog2.formData.resultNums,
        content:self.dialog2.formData.content,
        planStartTime: self.dialog2.formData.planStartTime?self.timestampToTime(self.dialog2.formData.planStartTime):null,
        planEndTime:self.dialog2.formData.planEndTime?self.timestampToTime(self.dialog2.formData.planEndTime):null,
        startTime:self.dialog2.formData.startTime?self.timestampToTime(self.dialog2.formData.startTime):null,
        endTime:self.dialog2.formData.endTime?self.timestampToTime(self.dialog2.formData.endTime):null,
    }
    testApi.updateTestProcess(data).then(res=>{
      self.$message.success(`${self.dialog2.title}成功`);
      self.dialog2.isShow = false;
      self.getRecordList();
    })
   }
  }
}
</script>
<style lang="stylus" scoped>

</style>